<template>
	<view class="content">
		<bing-lyric :lyrics="lyrics" :centerStyle="centerStyle" :curTime="curTime" :areaStyle="cuAreaStyle"
			:lyricStyle="lyricStyle" @centerBtnClick="centerBtnClick" @copyLyrics="copy"></bing-lyric>
		<!-- <music></music> -->
		<Audio :obeyMuteSwitch="true" style="width: 100%;" :poster="music.cover" :src="music.url" :name="music.name" author="lizhi"></Audio>
	</view>
</template>

<script>
	import bingLyric from '../../components/bing-lyric/bing-lyric.vue'
	import music from '../../components/music/music.vue'
	import Audio from '../../components/audio.vue'

	export default {
		components: {
			bingLyric,
			Audio,
		},
		data() {
			return {
				title: 'Hello',
				centerStyle: {
					btnImg: '../../static/btn.png',
				},
				lyricStyle: {},
				cuAreaStyle: {
					width: '100vw',
					height: 'calc(100vh - 115px)'
				},
				lyrics: [],
				curTime: 0,
				music: {
					"artist": "专辑-108个关键词",
					"artistId": "6722372454ea7803b905f3f3",
					"name": "倒影",
					"url": "https://testingcf.jsdelivr.net/gh/nj-lizhi/song@main/audio/108个关键词/倒影.mp3",
					"lyric": [],
					"cover": "https://testingcf.jsdelivr.net/gh/nj-lizhi/song@main/audio/Imagine-2011/cover.png"
				}
			}
		},
		onLoad() {
			this.makeTime()
		},
		mounted() {
			uniCloud.callFunction({
				name: 'initData',
			}).then((res) => {
				console.log(res)
			}).catch((err) => {
				console.error(err)
			})
		},
		methods: {
			copy(e) {
				console.log('index', e)
				uni.showModal({
					content: JSON.stringify(e.lyrics)
				})
			},
			centerBtnClick(e) {
				console.log(e)
				this.curTime = e.centerTime
			},
			makeTime() {
				let i = 0
				for (i; i < 500; i++) {
					setTimeout(this.out, i * 500, 0.5)
				}
			},
			out(t) {
				this.curTime += t
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 100%;
	}
</style>